<%-- 
  - Author: Abed Yaseen
  - Date: 02-Jan-2012
  - Copyright Notice: TRAKHEES
  - Description: form.jsp
 --%>
 <%@ include file="/WEB-INF/view/include.jsp"%>

    <div class="t_tmiddle-right">
    	<div id="tabs">
	      <ul id="TabHeader">
	        <li><a href="#EmployeeDetails"><spring:message code="header.employee_details" /></a></li>
	        <li><a href="#PassportDetails"><spring:message code="header.passport_details" /></a></li>
	        <li><a href="#PersonalDetails"><spring:message code="header.personal_details" /></a></li>
	        <li><a href="#AddressDetails"><spring:message code="header.address_details" /></a></li>
	        <li><a href="#Comments"><spring:message code="header.comments" /></a></li>
	        <li><a href="#Attachments"><spring:message code="header.attachments" /></a></li>
	        <li><a href="#Summary"><spring:message code="header.summary" /></a></li>
	      </ul>
	      
	      <spring:hasBindErrors
						name="filesIncomingBean">
								<script type="text/javascript">
								$(document).ready(
										function() {
											jAlert('error', '<li><div style="color:red;"><spring:message code="${errors.allErrors[0].code}" text="${errors.allErrors[0].defaultMessage}"/></div></li>',
													'<spring:message code="label.errormessage" />');
										});
								</script>
		    </spring:hasBindErrors>
	      
	      <form:form modelAttribute="EmploymentVisaLicenseInfo" name="EmploymentVisaFrm"  id="EmploymentVisaFrm"  method="POST" enctype="multipart/form-data" class="t_form">
			<spring:hasBindErrors
						name="EmploymentVisaLicenseInfo">
							<script type="text/javascript">
								$(document).ready(
										function() {
											jAlert('error', '<li><form:errors path="*" delimiter="<li>"/>',
													'<spring:message code="label.errormessage" />');
										});
					</script>
		    </spring:hasBindErrors>
		  
				<%@include file="EmployeeDetailsTab.jsp" %>
				<%@include file="PassportDetailsTab.jsp" %>
				<%@include file="PersonalDetailsTab.jsp" %>
	       		<%@include file="AddressDetailsTab.jsp" %>
				<%@include file="CommentsTab.jsp" %>
	        	<%@include file="AttachmentsTab.jsp" %>
	       
				<%@include file="SummaryTab.jsp" %>
				<div id="FNPPaymentInfoTab" class="t_pop_up"> 
	        	  <%@include file="../../../admin/general/payment/PaymentInfoTab.jsp" %>
	        	</div>
	        	<div id="backgroundPopup"></div>
		    	
		    <c:choose>
				<c:when	test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
						<c:if test='${param.empsource == "0"}'>
							<a id="termsAndConditionLink" href="resources/staticContents/termsAndConditions/EmploymentVisa/outsideTermsAndCondition_ar.jsp" style="display:none; ">terms and condition</a>
						</c:if>
						<c:if test='${param.empsource == "1"}'>
							<a id="termsAndConditionLink" href="resources/staticContents/termsAndConditions/EmploymentVisa/insideTermsAndCondition_ar.jsp" style="display:none; ">terms and condition</a>
						</c:if>
						<c:if test='${param.empsource == "2"}'>
							<a id="termsAndConditionLink" href="resources/staticContents/termsAndConditions/EmploymentVisa/internalTermsAndCondition_ar.jsp" style="display:none; ">terms and condition</a>
						</c:if>
						<c:if test='${param.empsource == "3"}'>
							<a id="termsAndConditionLink" href="resources/staticContents/termsAndConditions/EmploymentVisa/sponsorshipTermsAndCondition_ar.jsp" style="display:none; ">terms and condition</a>
						</c:if>
				</c:when>
				<c:otherwise>
						<c:if test='${param.empsource == "0"}'>
							<a id="termsAndConditionLink" href="resources/staticContents/termsAndConditions/EmploymentVisa/outsideTermsAndCondition_en.jsp" style="display:none; ">terms and condition</a>
						</c:if>
						<c:if test='${param.empsource == "1"}'>
							<a id="termsAndConditionLink" href="resources/staticContents/termsAndConditions/EmploymentVisa/insideTermsAndCondition_en.jsp" style="display:none; ">terms and condition</a>
						</c:if>
						<c:if test='${param.empsource == "2"}'>
							<a id="termsAndConditionLink" href="resources/staticContents/termsAndConditions/EmploymentVisa/internalTermsAndCondition_en.jsp" style="display:none; ">terms and condition</a>
						</c:if>
						<c:if test='${param.empsource == "3"}'>
							<a id="termsAndConditionLink" href="resources/staticContents/termsAndConditions/EmploymentVisa/sponsorshipTermsAndCondition_en.jsp" style="display:none; ">terms and condition</a>
						</c:if>
				</c:otherwise>
			</c:choose>
	        	
		 </form:form>
	      
       </div>
    </div>
    <!--Middle Right Close-->
<script>

        var $tabs ;
        
        var visaType = '<%= request.getParameter("visatype")%>';
		var empSource = '<%= request.getParameter("empsource")%>'; 
        
		//Validation - Required fields
		$().ready(function() {
			 
			$("#termsAndConditionLink").fancybox({
				'width'				: '60%',
				'height'			: '70%',
		        'autoScale'     	: false,
		        'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe',
				'modal'				:'true'
			});
			
			var checkTrmsAndCondsCookie = null;
			
			if(empSource == '0'){
				checkTrmsAndCondsCookie = $.cookie('evouttrmsconds');
			}else if (empSource == '1'){
				checkTrmsAndCondsCookie = $.cookie('evintrmsconds');
			}else if (empSource == '2'){
				checkTrmsAndCondsCookie = $.cookie('evtintrnlrmsconds');
			}else if (empSource == '3'){
				checkTrmsAndCondsCookie = $.cookie('evspnshptrmsconds');
			}
		
			if(checkTrmsAndCondsCookie == null){
				$("#termsAndConditionLink").trigger('click');
			}

			
			$(".topnav").accordion({
				accordion:false,
				speed: 500,
				closedSign: '<img src=\'resources/images/common/close.jpg\' />',
				openedSign: '<img src=\'resources/images/common/open.jpg\' />'
			});
	
			$( "#PassportDetails #issueDate,#PassportDetails #expiryDate,#PersonalDetails #dateOfBirth" ).datepicker({
				showOn: "button",
				buttonImage: "resources/images/calender.jpg",
				dateFormat : 'dd/mm/yy',
				buttonImageOnly: true,
				changeMonth:true,
				changeYear:true,
				minDate: new Date(1900,1 - 1 ,1),
				yearRange:'c-50:c+10'
			});
		
	
			if($('#strNationality').val() != "" && $('#strNationality').val() != null){
				updateCity();
			}
			
			if($('#strEmirate').val() != "" && $('#strEmirate').val() != null){
				updateEmirateCity();
			}
			
			$('#strNationality').change(function() {
	        	updateCity();
	    	});
			
			$('#strOriginCity').change(function() {
				updateAirFare();
	    	});
	    	
	    	$('#strEmirate').change(function() {
	        	updateEmirateCity();
	    	});
	    	
	    	$('#strOriginCity').change(function() {
				updateAirFare();
	    	});
	    	
	    	$.validator.addMethod(
		        "regex",
		        function(value, element, regexp) {
		            
		            var re = new RegExp(regexp);
		            return this.optional(element) || re.test(value);
		        }
		      
			);
	    	
	    	$.validator.addMethod(
			        "phoneRegex",
			        function(value, element, regexp) {
			            
			            var re = new RegExp(regexp);
			            return this.optional(element) || re.test(value);
			        }
			    
			);
	    	
	    	$.validator.addMethod(
					"pastDate", 
					function() {
								var issueDate = new Date(formatDate($("#issueDate").val()));
		        				var today = new Date();
		        				return (issueDate < today);
		   		 });
			
	    	$.validator.addMethod(
					"passportExpiryDate", 
					function() {
		        				var expiryDate = new Date(formatDate($("#expiryDate").val()));
		        				var sixMonthFromNow = new Date();
		        				sixMonthFromNow.setMonth(sixMonthFromNow.getMonth() +6);
		        				return ( expiryDate >= sixMonthFromNow);
		    });
	    	
	    	$.validator.addMethod(
					"dateFormatValid", 
					function(value, element) {
		        				return !!Date.parseExact(value, 'dd/MM/yyyy');
		    });
	    	
	    	$.validator.addMethod(
					"candidate18Year", 
					function() {
		        				var birthOfDate = new Date(formatDate($("#dateOfBirth").val()));
		        				var canditateDate = new Date();
		        				canditateDate.setFullYear(canditateDate.getFullYear() -18);
		        				return ( birthOfDate < canditateDate);
		    });
			 $.validator.addMethod(
					"lowsalary", 
					function(value) {
		        				return (value >= 1000);
		    });
			   	
	     	$.validator.addMethod(
			        "upperRegex",
			        function(value, element, regexp) {
			        	var flag = (/[a-z]/.test(value));
			            return !flag;
			        }
				);
	    	
			$("#EmploymentVisaFrm").validate({

				onfocusout:false,
				onkeyup:false,
				onclick: false,			
				rules : {
					//Employee Details
					employeeType : "required",
					employeeSource : "required",
						strNameInPassport : {
						 required :true,
						 upperRegex: "/[a-z]/" 
					},
					strOriginCity : "required",
					salary :{
					 required :true,
					 regex: "^[0-9]+$",
					  lowsalary:true
					 },
					strFoodAllowance : "required",
					jobCode : "required",
					strPriority :"required",
					strGender : "required",
					
					strIDCardFlag: "required",
					rpPeriod: "required",
					airFare:{
						 required :false,
						 regex: "^[0-9]+$"
					},
					strOtherAllowance: "required",
					strAccommodationAllowance: "required",
					strTransportation: "required",
					strNationality: "required",
					strReligion: "required",
					strMaritalStatus: "required",
					strBankGuranteeFlag: "required",
					//Passport Details
						
						strPassportNo : {
						 required :true,
						 upperRegex: "/[a-z]/" 
					},
					strCountryOfIssue: "required",
					issueDate: {
						required : true,
						pastDate: true,
						dateFormatValid : true
					},
					expiryDate: {// compound rule
						required : true,
						passportExpiryDate:true,
						dateFormatValid : true
					},
					strCityOfIssue: "required",
					//Personal Details
					strFatherName: "required",
					strMotherName: "required",
					dateOfBirth: {// compound rule
						required : true,
						candidate18Year:true,
						dateFormatValid : true
					},
					strBirthPlace: "required",
					qualification: "required",
					spokenLanguage1: "required",
					//Address Details
					strCurentlyInUAE: "required",
					strAddressAbroad: "required",
					strTelephoneOffice:{
						required : false,
						phoneRegex:"^(\\+?([0-9-]){6,14}[0-9])?$"
					},
					strTelephoneRisidence:{
						required : false,
						phoneRegex:"^(\\+?([0-9-]){6,14}[0-9])?$"
					},
					
					
					//Attachments
					passportCopy : "required",
					letterFromCompany: "required",
					photograph: "required"
					//InsurancePaper: "required",
					//cancellationOrVisitCopy: "required",
					//cancellationPaper: "required"
				},
				
				submitHandler: function (form) {
					blockPage();
					form.submit();
				},
				
				showErrors : function(errorMap, errorList) {
					
					var errors = '<ul>';
					var label;				
					if (errorList.length) {
						$.each(errorMap, function(name, value) {
							label = $("label[for='" + name + "']").html();
							label = value + '[' + label + ']';
							errors = errors + '<li>' + label + '</li>';
							

						});
						errors = errors + '</ul>';
						jAlert('error', errors, '<spring:message code="label.errormessage" />');
						return false;
					}
				}		
			});// end $("#EmploymentVisaFrm").validate

			$tabs = $("#tabs").tabs();	
			$('#TabHeader').removeClass('ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all');
			$('#TabHeader > li').removeClass('ui-state-default ui-corner-top ui-state-active ui-state-hover');
			$('#tabs').removeClass('ui-widget ui-widget-content ui-corner-all');
			
			$('#tabs').tabs({
				select : function(event, ui) {
					
					var selected = $tabs.tabs('option', 'selected'); // => 0
					var clicked = ui.index; // => 0
										
					if( selected > clicked )
						return true;
					
					var isValid = validate(clicked);// form validation returning true or false
					
					
					if(clicked == 6){
						updateSummaryTab();
						updateAttachmentsTab();
					}else if(clicked == 5){
						updateAttachmentsTab();
					}
					
					return isValid;
				}
			});
			
	
			$('#EmployeeDetails-Next').click(function() { // bind click event to link			
				$tabs.tabs('select', 1);
				return false;
				//$('#EmploymentVisaFrm').submit();
			});
			
			$('#PassportDetails-Next').click(function() { // bind click event to link			
				$tabs.tabs('select', 2);
				return false;
			});
			
			$('#PersonalDetails-Next').click(function() { // bind click event to link			
				$tabs.tabs('select', 3);
				return false;
			});
			
			$('#AddressDetails-Next').click(function() { // bind click event to link			
				$tabs.tabs('select', 4);
				return false;
			});
			
			$('#Comments-Next').click(function() { // bind click event to link			
				$tabs.tabs('select', 5);
				return false;
			});
			
			$('#Attachments-Next').click(function() { // bind click event to link			
				$tabs.tabs('select', 6);
				return false;
			});
			
			//Prev Buttons
			$('#PassportDetails-Prev').click(function() { // bind click event to link			
				$tabs.tabs('select', 0);
				return false;
			});
			
			$('#PersonalDetails-Prev').click(function() { // bind click event to link			
				$tabs.tabs('select', 1);
				return false;
			});
			
			$('#AddressDetails-Prev').click(function() { // bind click event to link			
				$tabs.tabs('select', 2);
				return false;
			});
			
			$('#Comments-Prev').click(function() { // bind click event to link			
				$tabs.tabs('select', 3);
				return false;
			});
			
			$('#Attachments-Prev').click(function() { // bind click event to link			
				$tabs.tabs('select', 4);
				return false;
			});
			
			
			if(visaType == 'employment'){
				$('#strVisaType').val('Employment Visa');
			}
			
			$('#strPostNo').val('Auto Generated');
			
			if(empSource != '0' && empSource != '1' ){ 
				$("select#strEntryPermitCollectionMethod").attr("disabled", true);
				$('select#strEntryPermitCollectionMethod >option').remove();
				$('<option/>').val("").html("No Need").appendTo('select#strEntryPermitCollectionMethod');
				//$("select#employeeSource option[selected]").removeAttr("selected");
				//$("select#employeeSource option[value='0']").attr("selected", "selected");
				//$("#select#employeeSource").change();
				//$("select#employeeSource").val("0");
			}
			
			
		});	
		
		function submitForm(divId){
				if(validate(7)){
					$('#EmploymentVisaFrm').append($("#"+divId).html());
					var input = $("<input>").attr("type", "hidden").attr("name", "submitted").val("submitted");
					$('#EmploymentVisaFrm').append($(input));
					$.fancybox.showLoading();
					$('#EmploymentVisaFrm').submit();
				} else {
					return false;
				}
		}
		
		function validate(clicked) {
				//var selected = $tabs.tabs('option', 'selected'); // => 0
				
				var result = true;
				if(clicked > 0)
				{
					result = result && ($("#EmploymentVisaFrm").validate().element("#employeeType")
							&& $("#EmploymentVisaFrm").validate().element("#employeeSource")
							&& $("#EmploymentVisaFrm").validate().element("#strNameInPassport")
							&& $("#EmploymentVisaFrm").validate().element("#strOriginCity")
							&& $("#EmploymentVisaFrm").validate().element("#salary")
							&& $("#EmploymentVisaFrm").validate().element("#strFoodAllowance")
							&& $("#EmploymentVisaFrm").validate().element("#jobCode")
							&& $("#EmploymentVisaFrm").validate().element("#strPriority")
							&& $("#EmploymentVisaFrm").validate().element("#strGender")
							&& $("#EmploymentVisaFrm").validate().element("#strMedicalType")
							&& $("#EmploymentVisaFrm").validate().element("#strIDCardFlag")
							&& $("#EmploymentVisaFrm").validate().element("#rpPeriod")
							&& $("#EmploymentVisaFrm").validate().element("#airFare")
							&& $("#EmploymentVisaFrm").validate().element("#strOtherAllowance")
							&& $("#EmploymentVisaFrm").validate().element("#strAccommodationAllowance")
							&& $("#EmploymentVisaFrm").validate().element("#strTransportation")
							&& $("#EmploymentVisaFrm").validate().element("#strNationality")
							&& $("#EmploymentVisaFrm").validate().element("#strReligion")
							&& $("#EmploymentVisaFrm").validate().element("#strMaritalStatus")
							&& $("#EmploymentVisaFrm").validate().element("#strBankGuranteeFlag")
							);
				}
				if(clicked > 1)
				{
					result = result &&  ($("#EmploymentVisaFrm").validate().element("#strPassportNo") 
							&& $("#EmploymentVisaFrm").validate().element("#strCountryOfIssue")
							&& $("#EmploymentVisaFrm").validate().element("#issueDate")
							&& $("#EmploymentVisaFrm").validate().element("#expiryDate")
							&& $("#EmploymentVisaFrm").validate().element("#strCityOfIssue")
							);
				}
				if(clicked > 2)
				{
					result = result && ($("#EmploymentVisaFrm").validate().element("#strFatherName") 
							&& $("#EmploymentVisaFrm").validate().element("#strMotherName")
							&& $("#EmploymentVisaFrm").validate().element("#dateOfBirth")
							&& $("#EmploymentVisaFrm").validate().element("#strBirthPlace")
							&& $("#EmploymentVisaFrm").validate().element("#qualification")
							&& $("#EmploymentVisaFrm").validate().element("#spokenLanguage1")
					);
				}
				
				if(clicked > 3)
				{
					result = result && ($("#EmploymentVisaFrm").validate().element("#strCurentlyInUAE") 
							&& $("#EmploymentVisaFrm").validate().element("#strAddressAbroad"));
					var telephoneOffice = $("#EmploymentVisaFrm").validate().element("#strTelephoneOffice");
					if(typeof telephoneOffice === "undefined"){
						telephoneOffice = true;
					}
					var telephoneResidence = $("#EmploymentVisaFrm").validate().element("#strTelephoneRisidence");
					if(typeof telephoneResidence === "undefined"){
						telephoneResidence = true;
					}
					
					result = result && telephoneOffice && telephoneResidence;
							
				}
				
				if (clicked > 5){
					
					var isMandatoryValid =($("#EmploymentVisaFrm").validate().element("#PassportCopy")
						&& $("#EmploymentVisaFrm").validate().element("#LetterFromCompany")
						&& $("#EmploymentVisaFrm").validate().element("#Photograph"));
						
					var isOptionalValid = true;
					var selectedOption = null;
					var medicalOption = null;
					if($.browser.msie && $.browser.version.substr(0,1)<7){
						selectedOption = $('#EmploymentVisaFrm #employeeSource').val();
						medicalOption = $('#EmploymentVisaFrm #strMedicalType').val();
					} else {
						selectedOption = $('#EmploymentVisaFrm select#employeeSource option:selected').val();
						medicalOption = $('#EmploymentVisaFrm select#strMedicalType option:selected').val();
					}
					
					if(selectedOption == "0"){
						
						if(medicalOption == "I"){
							isOptionalValid = ($("#EmploymentVisaFrm").validate().element("#InsurancePaper"));
						}
					}else if(selectedOption == "1" || selectedOption == "3"){
					
						isOptionalValid = ($("#EmploymentVisaFrm").validate().element("#cancellationOrVisitCopy"));
						if(medicalOption == "I"){
							isOptionalValid = isOptionalValid && ($("#EmploymentVisaFrm").validate().element("#InsurancePaper"));
						}
					
					}else if(selectedOption == "2"){
					
						isOptionalValid = ($("#EmploymentVisaFrm").validate().element("#cancellationPaper"));
					
					}
					
					result = result &&  (isMandatoryValid && isOptionalValid);
				
				}
				
				return result;
				//return true;
			}
			
			function validatePayment(){
				return ($("#EmploymentVisaFrm").validate().element("#fnpServiceCode"));
			}


		 var addressFormatting = function(text){
			var newText = text;
			//array of find replaces
			var findreps = [
				{find:/^([^\-]+) \- /g, rep: '<span class="ui-selectmenu-item-header">$1</span>'},
				{find:/([^\|><]+) \| /g, rep: '<span class="ui-selectmenu-item-content">$1</span>'},
				{find:/([^\|><\(\)]+) (\()/g, rep: '<span class="ui-selectmenu-item-content">$1</span>$2'},
				{find:/([^\|><\(\)]+)$/g, rep: '<span class="ui-selectmenu-item-content">$1</span>'},
				{find:/(\([^\|><]+\))$/g, rep: '<span class="ui-selectmenu-item-footer">$1</span>'}
			];
			
			for(var i in findreps){
				newText = newText.replace(findreps[i].find, findreps[i].rep);
			}
			return newText;
		}
		
		function updateSummaryTab(){
		
			if($.browser.msie && $.browser.version.substr(0,1)<7){
				$("#EmploymentVisaFrm input[type=hidden]").each(function() {	
		       		$('#Summary input#sum'+$(this).attr('id')).val($("#cuselFrame-"+$(this).attr('id')+" .cuselText").html());
		       		$('#Summary input#sum'+$(this).attr('id')).attr('disabled', true);
		
		    	});
			}
		//alert("updateSummaryTab");
		  	$("#EmploymentVisaFrm input[type=text]").each(function() {
		  		
				//alert('#Summary input#'+$(this).attr('id') + "--->" + this.value);
		       		$('#Summary input#sum'+$(this).attr('id')).val(this.value);
		       		$('#Summary input#sum'+$(this).attr('id')).attr('disabled', true);

		    });
		    
		    $("#EmploymentVisaFrm select").each(function() {
		       		
		       		$('#Summary input#sum'+$(this).attr('id')).val($('#EmploymentVisaFrm select#'+$(this).attr('id')+ ' option:selected').text());
		       		$('#Summary input#sum'+$(this).attr('id')).attr('disabled', true);

		    });
		    
		    $("#EmploymentVisaFrm input[type=file]").each(function() {

		       		$('#Summary input#sum'+$(this).attr('id')).val(this.value);
		       		$('#Summary input#sum'+$(this).attr('id')).attr('disabled', true);

		    });
		    
		    $("#EmploymentVisaFrm textarea").each(function() {

		       		$('#Summary textarea#sum'+$(this).attr('id')).val($(this).val());
		       		$('#Summary textarea#sum'+$(this).attr('id')).attr('disabled', true);

		    });
		    
		    <c:if test="${isCompanyAdmin}">
		    	$('#fnpServiceCode').rules("add", { required: true });
		    </c:if>
				  	
		
		}
		
		function updateAttachmentsTab(){
				
				var selectedOption = null;
				var medicalOption = null;
				if($.browser.msie && $.browser.version.substr(0,1)<7){
					selectedOption = $('#EmploymentVisaFrm #employeeSource').val();
					medicalOption = $('#EmploymentVisaFrm #strMedicalType').val();
				} else {
					selectedOption = $('#EmploymentVisaFrm select#employeeSource option:selected').val();
					medicalOption = $('#EmploymentVisaFrm select#strMedicalType option:selected').val();
				}
				
				
				$('label#cancellationOrVisitCopyLbl').removeClass("frm-req");
				$('input#cancellationOrVisitCopy').hide();
				$('input#cancellationOrVisitCopy').rules("add", { required: false });
				$('label#cancellationOrVisitCopyLbl').hide();
				//updates
				$('input#sumcancellationOrVisitCopy').hide();
				$('label#sumcancellationOrVisitCopyLbl').hide();
				
				$('label#cancellationPaperLbl').removeClass("frm-req");
				$('input#cancellationPaper').hide();
				$('input#cancellationPaper').rules("add", { required: false });
				$('label#cancellationPaperLbl').hide();
				//updates
				$('input#sumcancellationPaper').hide();
				$('label#sumcancellationPaperLbl').hide();
				
				$('label#InsurancePaperLbl').removeClass("frm-req");
				$('input#InsurancePaper').hide();
				$('input#InsurancePaper').rules("add", { required: false });
				$('label#InsurancePaperLbl').hide();
				//updates
				$('input#sumInsurancePaper').hide();
				$('label#sumInsurancePaperLbl').hide();
				
				if(selectedOption == "0"){
					
					if(medicalOption == "I"){
						$('input#InsurancePaper').show();
						$('input#InsurancePaper').rules("add", { required: true });
						$('label#InsurancePaperLbl').show();
						$('label#InsurancePaperLbl').addClass("frm-req");
						//updates
						$('input#sumInsurancePaper').show();
						$('label#sumInsurancePaperLbl').show();
					}
				}else if(selectedOption == "1" || selectedOption == "3"){
					
					$('input#cancellationOrVisitCopy').show();
					$('input#cancellationOrVisitCopy').rules("add", { required: true });
					$('label#cancellationOrVisitCopyLbl').show();
					$('label#cancellationOrVisitCopyLbl').addClass("frm-req");
					//updates
					$('input#sumcancellationOrVisitCopy').show();
					$('label#sumcancellationOrVisitCopyLbl').show();
					if(medicalOption == "I"){
						$('input#InsurancePaper').show();
						$('input#InsurancePaper').rules("add", { required: true });
						$('label#InsurancePaperLbl').show();
						$('label#InsurancePaperLbl').addClass("frm-req");
						//updates
						$('input#sumInsurancePaper').show();
						$('label#sumInsurancePaperLbl').show();
					}
				
				}else if(selectedOption == "2"){
				
					$('input#cancellationPaper').show();
					$('input#cancellationPaper').rules("add", { required: true });
					$('label#cancellationPaperLbl').show();
					$('label#cancellationPaperLbl').addClass("frm-req");
					//updates
					$('input#sumcancellationPaper').show();
					$('label#sumcancellationPaperLbl').show();
				}
			
		}
		
		function updateCity() {
		 
		 	$('#strOriginCity > option').remove();
		    $.getJSON("city.json",{contryCode:$("#strNationality").val()},
		    	 function(data) {
		    	$.each(data,function(key,city){ 		    		
		    		<c:choose>
		    			<c:when
		    				test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
		    					var label = city.labelAr;
		    			</c:when>
		    			<c:otherwise>
		    					var label =  city.labelEn;
		    			</c:otherwise>
		   			</c:choose>
		   			var id = city.id;
		   			if(id == '${EmploymentVisaLicenseInfo.strOriginCity}'){
		    			$('<option selected=selected/>').val(id).html(label).attr("airFare",city.airFare).appendTo('#strOriginCity');
		    		}else{
		    			$('<option/>').val(id).html(label).attr("airFare",city.airFare).appendTo('#strOriginCity');
		    		}
			    		
					});
		    	
		    
		    	   });
		    
		}
		
		function updateAirFare(){
			$("#airFare").val($("#strOriginCity option:selected").attr("airFare"));
		}
		  
		function updateEmirateCity() {
		  	
		  	$('#strCity > option').remove();
	    	$.getJSON("emiratecity.json",{emirateCode:$("#strEmirate").val()},
	    	 function(data) {
	    	$.each(data,function(key,city){ 		    		
	    		<c:choose>
	    			<c:when
	    				test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
	    					var label = city.labelAr;
	    			</c:when>
	    			<c:otherwise>
	    					var label =  city.labelEn;
	    			</c:otherwise>
	   			</c:choose> 
		    		var id = city.id;
	    			$('<option/>').val(id).html(label).appendTo('#strCity');
				   
				});
	    	
	    
	    	   });
		  
	   }
</script>

<!--[if IE 6]>
	<script>
		updateCity = function() {
		 	$('#cusel-scroll-strOriginCity > span').remove();
		 	$("#cuselFrame-strOriginCity .cuselText").html("");
		 	$("#strOriginCity").val("");
		    $.getJSON("city.json",{contryCode:$("#strNationality").val()},
		    	 function(data) {
				    	$.each(data,function(key,city){ 		    		
				    		<c:choose>
				    			<c:when
				    				test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
				    					var label = city.labelAr;
				    			</c:when>
				    			<c:otherwise>
				    					var label =  city.labelEn;
				    			</c:otherwise>
				   			</c:choose>
				   			var id = city.id;
				   			
				   			var selectedId = '${EmploymentVisaLicenseInfo.strOriginCity}';
				   			if(id == selectedId || (key == 0 && (selectedId=="" || selectedId==null))){
				    			$('<span class="cuselActive"></span>').attr("val",id).html(label).attr("airFare",city.airFare).appendTo('#cusel-scroll-strOriginCity');
				    			$("#strOriginCity").val(id=='null'?"":id);
				    			$("#cuselFrame-strOriginCity .cuselText").html(label);
				    		}else{
				    			$('<span></span>').attr("val",id).html(label).attr("airFare",city.airFare).appendTo('#cusel-scroll-strOriginCity');
				    		}
					    		
						});
						 var params = {
						    refreshEl: "#strOriginCity",
					        visRows: 5,
					        scrollArrows: true
					    }
		    			cuSelRefresh(params);
		    	   });
		    
		}
		updateAirFare = function(){
			var value = $("#strOriginCity").val();
			$("#airFare").val($("#cusel-scroll-strOriginCity span[val="+value+"]").attr("airFare"));
		}
		
		updateEmirateCity = function () {
		  	
		 	$('#cusel-scroll-strCity > span').remove();
		 	$("#cuselFrame-strCity .cuselText").html("");
		 	$("#strCity").val("");
		    $.getJSON("emiratecity.json",{emirateCode:$("#strEmirate").val()},
		    	 function(data) {
				    	$.each(data,function(key,city){ 		    		
				    		<c:choose>
				    			<c:when
				    				test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
				    					var label = city.labelAr;
				    			</c:when>
				    			<c:otherwise>
				    					var label =  city.labelEn;
				    			</c:otherwise>
				   			</c:choose>
				   			var id = city.id;
				   			
				   			var selectedId = '${EmploymentVisaLicenseInfo.strCity}';
				   			if(id == selectedId || (key == 0 && (selectedId=="" || selectedId==null))){
				    			$('<span class="cuselActive"></span>').attr("val",id).html(label).appendTo('#cusel-scroll-strCity');
				    			$("#strCity").val(id=='null'?"":id);
				    			$("#cuselFrame-strCity .cuselText").html(label);
				    		}else{
				    			$('<span></span>').attr("val",id).html(label).appendTo('#cusel-scroll-strCity');
				    		}
					    		
						});
						var params = {
						        refreshEl: "#strCity",
					        visRows: 5,
					        scrollArrows: true
					    }
		    			cuSelRefresh(params);
		    	   });
		  
	   }
	</script>	
<![endif]-->
